﻿<%@ Page Language="C#" MasterPageFile="~/Common/WebSiteMaster.master" AutoEventWireup="true" CodeBehind="A_StraightHTML.aspx.cs" Inherits="ScottCateAjax2008.Lesson01.A_StraightHTML" Title="Straight HTML - No Server" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script language="javascript" type="text/javascript">
    var xmlHttp = null;
    var response = null;
    var results = null;
        
    function InitXmlHttp() {	
    		results = document.getElementById('DisplayResults');
    		
		    try {
		    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");					
		    return;
		    } catch (ex) {}// catch
    		
		    try {
		    xmlHttp = new ActiveXObject("msxml2.xmlhttp");						
		    return;
		    } catch (ex) {}// catch
    		  		  		
		    try {
		    xmlHttp = new XMLHttpRequest();						
		    return;
		    } catch (ex) {}// catch
		    xmlHttp = null;	  
    	
    }// function

    function GetData(url) {
	    response = null;
	    if (!xmlHttp) InitXmlHttp();
	    
	    if (xmlHttp && url) {
	        // run sync or async? true = script will continue
	        // false = script will wait for result
	        var async = false; 
		    xmlHttp.open ( 'GET', url, async );			
		    xmlHttp.send (null);

		    var content = xmlHttp.responseText;
		    if(content && results)
		        results.innerHTML = content;	
	    }// if
    }// function
    
    function ClearData() {
        if(results)
            results.innerHTML = '';
    }
    </script>    
    
    <a href="#GetHTML" 
       onclick="GetData('A_StraightHTMLResponse.htm');">Get Html response</a><br />

    <a href="#ClearHTML" 
       onclick="ClearData();">Clear Html response</a><br /><br />

    <a href="/Utilities/ShowServerCode.aspx?res=/Lesson01/A_StraightHTMLResponse.htm">Show A_StraightHTMLResponse.htm</a>
    
    <div id="DisplayResults">    
    </div>

</asp:Content>
